/*
 * @Author: hucc
 * @Date: 2021-09-26 09:54:36
 * @LastEditors: hucc
 * @LastEditTime: 2021-09-26 15:31:28
 * @Description: 
 */

//对象简写 省略的是key值 保留的是value值
//{属性名：变量名}         {变量名：变量值}
// let { name, age } = { name: "zs", age: 12 }
// console.log(name, age); //zs 12
// let { name: username, age: userage } = { name: "lisi", age: 18 }
// console.log(username, userage); //lisi 18
let { x: z } = { x: 1, y: 2 };
console.log(z); //1
//嵌套解构
// let obj = { p: ["hello", { y: "world" }] };
// let { p: [a, { y: b }] } = obj;
// console.log(a + b);//helloworld

//对象解构-设置默认值
// let { name, age, gender = "male" } = { name: "zs", age: 12 }
// console.log(name, age, gender);//zs 12 male

//对象解构-拓展运算符
let { a, ...b } = { a: 1, b: 2, c: 3 }
console.log(a, b); //1  { b: 2, c: 3 }
//拓展运算符完成对象深拷贝 深克隆
let obj = { a: 1, b: 2, c: 3 }
let {...b1 } = obj;
console.log(b1 === obj); //false